package com.hrsoft.edi.stub;

import cn.hutool.json.JSONObject;
import com.hrsoft.edi.stub.consant.AppInfo;
import com.hrsoft.edi.stub.request.ItemsSynchronizeRequest;
import com.hrsoft.edi.stub.request.SingleitemSynchronizeRequest;
import com.qimen.api.DefaultQimenClient;
import com.qimen.api.QimenClient;
import com.qimen.api.response.ItemsSynchronizeResponse;
import com.qimen.api.response.SingleitemSynchronizeResponse;
import com.taobao.api.ApiException;

import java.util.ArrayList;
import java.util.List;

public class ItemsSynchronizeTest
{
    public static void main(String[] args)
    {
        ItemsSynchronizeRequest itemsSynchronizeRequest = new ItemsSynchronizeRequest();
        itemsSynchronizeRequest.setCustomerId("1002");

        List<ItemsSynchronizeRequest.Item> itemList = new ArrayList<>();
        ItemsSynchronizeRequest.Item item1 = new ItemsSynchronizeRequest.Item();
        item1.setItemCode("0001");
        item1.setItemName("0001");
        item1.setBarCode("0001");
        item1.setStockUnit("个");
        item1.setItemType("ZP");
        itemList.add(item1);

        ItemsSynchronizeRequest.Item item2 = new ItemsSynchronizeRequest.Item();
        item2.setItemCode("0002");
        item2.setItemName("0002");
        item2.setBarCode("0002");
        item2.setItemType("ZP");
        itemList.add(item2);
        itemsSynchronizeRequest.setItems(itemList);
        itemsSynchronizeRequest.setOwnerCode(AppInfo.OWNER_CODE);
        QimenClient client = new DefaultQimenClient(AppInfo.URL, AppInfo.APP_KEY, AppInfo.SECRET);
        try
        {
            ItemsSynchronizeResponse response = client.execute(itemsSynchronizeRequest);
            System.out.println(new JSONObject(response));
        }
        catch (ApiException e)
        {
            e.printStackTrace();
        }
    }
}
